package com.dys.test06;

/**
 * @className: com.dys.test06.ThreadTest
 * @description: com.dys.test06
 * @author: pine cone
 * @version: v1.0.0
 * @createTime: 2024/08/17 下午10:48
 */
public class ThreadTest extends Thread {

    public ThreadTest(String name) {
        super(name);
    }

    @Override
    public void run() {
        for (int i = 1; i <= 10; i++) {
            System.out.println(Thread.currentThread().getName() + ":" + i);
        }
    }
}

class ThreadTest02 extends Thread {
    public ThreadTest02(String name) {
        super(name);
    }

    @Override
    public void run() {
        for (int i = 20; i <= 30; i++) {
            System.out.println(Thread.currentThread().getName() + "--->" + i);
        }
    }
}

class Test {
    /**
     * 这是一个main()方法,是应用程序的入口
     *
     * @param args 方法的形参列表,是一个字符串数组,包含了从命令行传递给程序的参数
     */
    public static void main(String[] args) {
        ThreadTest t1 = new ThreadTest("子线程1");
        // 设置优先级别最高
        t1.setPriority(10);
        t1.start();

        ThreadTest02 t2 = new ThreadTest02("子线程2");
        // 设置优先级别最低
        t2.setPriority(1);
        t2.start();
    }
}